<?php 
 
namespace app\common\model;

use app\common\model\BaseModel;
use app\common\traits\ModelTrait;
use app\common\utils\JsonService;
/**
* This is the model class for table "{ptf_shop}".
*
* @property int $shop_id 店铺索引id 
* @property string $shop_name 店铺名称
* @property int $shop_type_id 店铺等级 
* @property string $shop_type_name 店铺等级名称
* @property int $member_id 会员id 
* @property int $shop_group_id 店铺分类 
* @property string $shop_group_name 店铺类型名称
* @property string $company_name 店铺公司名称
* @property int $province_id 店铺所在省份ID 
* @property int $city_id 店铺所在市ID 
* @property int $district_id 所在地区ID 
* @property string $address_detail 公司详细地址
* @property string $shop_zip 邮政编码
* @property int $shop_status 店铺状态0：关闭,1:开启 
* @property string $shop_close_info 店铺关闭原因
* @property int $shop_sort 店铺排序 
* @property int $shop_create_time 店铺时间 
* @property int $shop_end_time 店铺关闭时间 
* @property string $shop_logo 店铺logo
* @property string $shop_banner 店铺横幅
* @property string $shop_avatar 店铺头像
* @property string $shop_keywords 店铺seo关键字
* @property string $shop_description 店铺seo描述
* @property string $shop_qq QQ
* @property string $shop_ww 阿里旺旺
* @property string $shop_phone 商家电话
* @property string $shop_domain 店铺二级域名
* @property int $shop_domain_times 二级域名修改次数 
* @property int $shop_recommend 推荐，0为否，1为是，默认为0 
* @property int $shop_credit 店铺信用 
* @property int $shop_desccredit 描述相符度分数
* @property int $shop_servicecredit 服务态度分数
* @property int $shop_deliverycredit 发货速度分数
* @property int $shop_collect 店铺收藏数量 
* @property string $shop_stamp 店铺印章
* @property string $shop_printdesc 打印订单页面下方说明文字
* @property int $shop_sales 店铺销售额（不计算退款） 
* @property int $shop_account 店铺账户余额 
* @property int $shop_cash 店铺可提现金额 
* @property string $shop_workingtime 工作时间
* @property string $live_store_name 商铺名称
* @property string $live_store_address 商家地址
* @property string $live_store_tel 商铺电话
* @property string $live_store_bus 公交线路
* @property string $shop_vrcode_prefix 商家兑换码前缀
* @property int $store_qtian 7天退换 
* @property int $shop_zhping 正品保障 
* @property int $shop_erxiaoshi 两小时发货 
* @property int $shop_tuihuo 退货承诺 
* @property int $shop_shiyong 试用中心 
* @property int $shop_shiti 实体验证 
* @property int $shop_xiaoxie 消协保证 
* @property int $shop_huodaofk 货到付款 
* @property string $shop_free_time 商家配送时间
* @property string $shop_region 店铺默认配送区域
* @property int $recommend_uid 推荐招商员用户id 
* @property string $shop_qrcode 店铺公众号
* @property int $shop_platform_commission_rate 平台抽取佣金比率 
*/
class Shop extends BaseModel{

    protected $pk = 'shop_id';
    protected $name = 'shop';

    use ModelTrait;
    protected $autoWriteTimestamp = true;
    //protected $dateFormat = 'Y-m-d';
    //protected $createTime = 'create_time';
    //protected $updateTime = 'update_time';

    /**
    * {@inheritdoc}
    */
    public function attributeLabels()
    {
        return [
            'shop_id' => '店铺索引id',
            'shop_name' => '店铺名称',
            'shop_type_id' => '店铺等级',
            'shop_type_name' => '店铺等级名称',
            'member_id' => '会员id',
            'shop_group_id' => '店铺分类',
            'shop_group_name' => '店铺类型名称',
            'company_name' => '店铺公司名称',
            'province_id' => '店铺所在省份ID',
            'city_id' => '店铺所在市ID',
            'district_id' => '所在地区ID',
            'address_detail' => '公司详细地址',
            'shop_zip' => '邮政编码',
            'shop_status' => '店铺状态0：关闭,1:开启',
            'shop_close_info' => '店铺关闭原因',
            'shop_sort' => '店铺排序',
            'shop_create_time' => '店铺时间',
            'shop_end_time' => '店铺关闭时间',
            'shop_logo' => '店铺logo',
            'shop_banner' => '店铺横幅',
            'shop_avatar' => '店铺头像',
            'shop_keywords' => '店铺seo关键字',
            'shop_description' => '店铺seo描述',
            'shop_qq' => 'QQ',
            'shop_ww' => '阿里旺旺',
            'shop_phone' => '商家电话',
            'shop_domain' => '店铺二级域名',
            'shop_domain_times' => '二级域名修改次数',
            'shop_recommend' => '推荐，0为否，1为是，默认为0',
            'shop_credit' => '店铺信用',
            'shop_desccredit' => '描述相符度分数',
            'shop_servicecredit' => '服务态度分数',
            'shop_deliverycredit' => '发货速度分数',
            'shop_collect' => '店铺收藏数量',
            'shop_stamp' => '店铺印章',
            'shop_printdesc' => '打印订单页面下方说明文字',
            'shop_sales' => '店铺销售额（不计算退款）',
            'shop_account' => '店铺账户余额',
            'shop_cash' => '店铺可提现金额',
            'shop_workingtime' => '工作时间',
            'live_store_name' => '商铺名称',
            'live_store_address' => '商家地址',
            'live_store_tel' => '商铺电话',
            'live_store_bus' => '公交线路',
            'shop_vrcode_prefix' => '商家兑换码前缀',
            'store_qtian' => '7天退换',
            'shop_zhping' => '正品保障',
            'shop_erxiaoshi' => '两小时发货',
            'shop_tuihuo' => '退货承诺',
            'shop_shiyong' => '试用中心',
            'shop_shiti' => '实体验证',
            'shop_xiaoxie' => '消协保证',
            'shop_huodaofk' => '货到付款',
            'shop_free_time' => '商家配送时间',
            'shop_region' => '店铺默认配送区域',
            'recommend_uid' => '推荐招商员用户id',
            'shop_qrcode' => '店铺公众号',
            'shop_platform_commission_rate' => '平台抽取佣金比率',
        ];
    }

    public function getMember(){
        return $this->hasOne('Member','id','member_id');
    }

    public static function getShopInfo($shop_id = 0){
        $data = [];
        if(!$shop_id){
            return [];
        }
        $data['shop'] = self::findModel($shop_id,[]);
        //取出分类
        $data['shopCategory'] = ShopCategory::getAllCategory($shop_id);
        return $data;
    }
}


?>